<?php
if(!interface_exists('XFilter', false)){
	require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'XFilter.php');
}
abstract class XAbstractFilter implements XFilter{
	protected $config = array();
	protected $breakChain = false;
	
	public function __construct(array $config = array()){
		$this->config = $config;
	}
	
	final public function doFilter(XServletRequest $request, XServletResponse $response, XFilterChain $chain){
		$this->beforeFilter($request, $response);
		if(!$this->breakChain){			
			$chain->doFilter($request, $response);
		}
		$this->afterFilter($request, $response);
	}
	
	protected function beforeFilter(XServletRequest $request, XServletResponse $response){
		
	}
	
	protected function afterFilter(XServletRequest $request, XServletResponse $response){
		
	}
	
	protected function setBreakChain($breakChain){
		$this->breakChain = $breakChain;
	}	
}
?>